import 'package:flutter/material.dart';

class BottomPage extends StatefulWidget {
  const BottomPage({Key? key}) : super(key: key);

  @override
  _BottomPageState createState() => _BottomPageState();
}

class _BottomPageState extends State<BottomPage> {
  int currentIndex = 0;
  int type = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // resizeToAvoidBottomInset: true,/*可以通过设置 这个属性 防止键盘 覆盖内容 或者 键盘 撑起内容*/
      appBar: AppBar(
        automaticallyImplyLeading: true, //false 使导航没有返回按钮
        title: const Text(''),
      ),
      body: Container(
        padding: const EdgeInsets.only(bottom: 20, right: 20),
        alignment: Alignment.bottomRight,
        child: ElevatedButton(
          child: const Icon(Icons.add),
          onPressed: () {
            setState(() {
              type++;
              if (type == 5) {
                type = 0;
              }
              // showToast("$type");
            });
          },
        ),
      ),
      // backgroundColor: Colors.blue.shade100,
      bottomNavigationBar: getWidget(),

      floatingActionButton: getFloatButton(),

      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
    );
  }

  Widget getFloatButton() {
    if (type == 0) {
      return FloatingActionButton(
        //   // isExtended: true,
        //   // shape: OutlineInputBorder(),
        // clipBehavior: Clip.antiAliasWithSaveLayer,
        onPressed: () {},
        child: const Icon(Icons.add),
      );
    }
    if (type == 1) {
      return FloatingActionButton(
        //   // isExtended: true,
        //   // shape: OutlineInputBorder(),
        // clipBehavior: Clip.antiAliasWithSaveLayer,
        onPressed: () {},
        child: const Icon(Icons.add),
      );
    }
    if (type == 2) {
      return FloatingActionButton.extended(
          shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(100)),
          onPressed: () {},
          label: IconButton(onPressed: () {}, icon: const Icon(Icons.ac_unit)));
    }
    if (type == 3) {
      return FloatingActionButton.extended(
          shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(10)),
          onPressed: () {},
          label: IconButton(onPressed: () {}, icon: const Icon(Icons.ac_unit)));
    }

    // return FloatingActionButton.large(onPressed: (){});
    // return FloatingActionButton.small(onPressed: (){});
    return FloatingActionButton.extended(
        // shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(100)),
        onPressed: () {},
        icon: const Icon(Icons.access_alarm_rounded),
        label: IconButton(onPressed: () {}, icon: const Icon(Icons.ac_unit)));
  }

  Widget getWidget() {
    if (type == 0) {
      return BottomNavigationBar(
        selectedItemColor: Colors.blue,
        currentIndex: currentIndex,
        items: const [
          BottomNavigationBarItem(icon: Icon(Icons.accessibility_new), label: "首页", activeIcon: Icon(Icons.ac_unit)),
          BottomNavigationBarItem(icon: Icon(Icons.menu), label: "我的", activeIcon: Icon(Icons.access_alarm)),
        ],
        onTap: (value) {
          setState(() {
            currentIndex = value;
          });
        },
        type: BottomNavigationBarType.fixed,

        // notchMargin: 10,
        elevation: 8.0,
      );
    }
    if (type == 1) {
      return BottomAppBar(
        shape: const CircularNotchedRectangle(),
        // shape: AutomaticNotchedShape(CircleBorder()),
        // notchMargin: 10,
        elevation: 8.0,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            IconButton(onPressed: () {}, icon: const Icon(Icons.airplanemode_on_rounded)),
            IconButton(onPressed: () {}, icon: const Icon(Icons.access_alarms)),
            IgnorePointer(
              child: IconButton(
                  onPressed: () {},
                  icon: const Icon(
                    Icons.ac_unit,
                    color: Colors.transparent,
                  )),
            ),
            IconButton(onPressed: () {}, icon: const Icon(Icons.account_balance_rounded)),
            IconButton(onPressed: () {}, icon: const Icon(Icons.mail)),
          ],
        ),
      );
    }
    if (type == 2) {
      return BottomAppBar(
        shape: AutomaticNotchedShape(
            const RoundedRectangleBorder(), BeveledRectangleBorder(borderRadius: BorderRadius.circular(100))),
        // notchMargin: 10,
        elevation: 8.0,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            IconButton(onPressed: () {}, icon: const Icon(Icons.ac_unit)),
            IconButton(onPressed: () {}, icon: const Icon(Icons.add)),
          ],
        ),
      );
    }
    if (type == 3) {
      return BottomAppBar(
        shape: AutomaticNotchedShape(
            const RoundedRectangleBorder(), BeveledRectangleBorder(borderRadius: BorderRadius.circular(10))),
        // notchMargin: 10,
        elevation: 8.0,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            IconButton(onPressed: () {}, icon: const Icon(Icons.ac_unit)),
            IconButton(onPressed: () {}, icon: const Icon(Icons.add)),
          ],
        ),
      );
    }
    return BottomAppBar(
      shape: const AutomaticNotchedShape(RoundedRectangleBorder(), StadiumBorder(side: BorderSide())),
      // notchMargin: 10,
      elevation: 8.0,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: [
          IconButton(onPressed: () {}, icon: const Icon(Icons.ac_unit)),
          IconButton(onPressed: () {}, icon: const Icon(Icons.add)),
        ],
      ),
    );
  }
}
